/*
 *   Clovis
 *   Copyright (C) 2008 SFWOL
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include "InputDevice.h"

namespace clovis {

	namespace io {

        InputDevice::InputDevice(){

            m = new Mouse();
            k = new Keyboard();

        }

        void InputDevice::manage(){
            SDL_Event event;
            SDL_PollEvent(&event);
            switch (event.type) {

                case SDL_QUIT:
                    Log::logOn(WARNING,"Quitte le tout");
                    exit(0);
                    break;

                case SDL_MOUSEMOTION:
                    m->setPosition(event.motion.x , event.motion.y);
                    break;

                case SDL_MOUSEBUTTONDOWN:
                    m->setPosition(event.button.x, event.button.y);

                    switch(event.button.button){
                        case SDL_BUTTON_LEFT:
                            Log::logOn(WARNING,"Clic Gauche");
                            m->stateLeft(true);
                            break;

                        case SDL_BUTTON_RIGHT:
                            Log::logOn(WARNING,"Clic droit");
                            m->stateRight(true);
                            break;

                        case SDL_BUTTON_MIDDLE:
                            Log::logOn(WARNING,"Clic milieu");
                            m->stateMiddle(true);
                            break;

                        default:
                            break;
                    }

                default:
                    //Log::logOn(WARNING,"Evenement non gere");
                    break;

            }

        }





	}

}
